(function() {
	//'strict';
	require(['jquery', 'form'], function(jquery) {
		if(typeof jQuery === 'undefined') {	//检测jquery依赖项
			throw new Error('jquery依赖项未能加载');
		}
		
		if(typeof $.fn.form === 'undefined') {
			throw new Error('form依赖项未能加载');
		}	
		
		/*验证添加*/
		$('#change_password_form').bootstrapValidator({
	        feedbackIcons: {
	            valid: 'glyphicon glyphicon-ok',
	            invalid: 'glyphicon glyphicon-remove',
	            validating: 'glyphicon glyphicon-refresh'
	        },
	        fields: {
	        	oldpassword: {
	        		trigger: 'blur',
	                validators: {
	                    notEmpty: {
	                        message: '旧密码不能为空'
	                    },
	                    callback: {
	                    	message: '旧密码输入错误!',
	                        callback: function(value, validator) {
	                        	var flag = false;
	                        	var username = orange.getAppContext('USER')['username'];
	                        	$.ajax({
	                        		/*url路径未添加*/
	                				url: 'user/validateUserOldPasseord.service',
	                				type: 'post',
	                				async: false,
	                				data: {
	                					username:username,
	                					password: value
	                					},
	                				success: function(data) {
	                					if(data && data.success){
	                						flag = true;
	                					}else{
	                						flag = false;
	                					}
	                				}
	                			});
	                        	return flag;
	                        }
	                    }
	                }
	            },
	            newpassword: {
	            	trigger: 'blur',
	                validators: {
	                    notEmpty: {
	                        message: '密码不能为空!'
	                    },
	                    stringLength: {
	                        min: 6,
	                        max: 100,
	                        message: '密码长度在6--100个字符之间！'
	                    },
	                    different: {
	                        field: 'oldpassword',
	                        message: '新密码不能与旧密码重复！！！'
	                    }
	                }
	            },
	            confirmpassword: {
	            	trigger: 'blur',
	                validators: {
	                    notEmpty: {
	                        message: '请再次输入新密码！'
	                    },
	                    identical: {
	                        field: 'newpassword',
	                        message: '两次输入的密码不相同！'
	                    }
	                }
	            }
	        }
		});
	});
})();